#include <iostream>

using namespace std;

/**
 * Definition for binary tree */
struct TreeNode
{
    int val;
    TreeNode *left;
    TreeNode *right;
    TreeNode(int x) : val(x), left(NULL), right(NULL) {}
};

class Solution
{
public:
    int minDepth(TreeNode *root)
    {
        if(root==NULL)
            return 0;
        if(root->left==NULL&&root->right==NULL)
            return 1;

        if(root->left==NULL&&root->right!=NULL)
            return minDepth(root->right)+1;
        if(root->left!=NULL&&root->right==NULL)
            return minDepth(root->left)+1;

        int leftDepth=minDepth(root->left);
        int rightDepth=minDepth(root->right);

        return(min(leftDepth,rightDepth)+1);
    }

private:
    int min(int a,int b)
    {
        if(a<=b)
            return a;
        return b;
    }
};

int main()
{
    cout<<"hello"<<endl;
}